/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TopFrame.java
 *
 * Created on 6-gen-2009, 12.44.01
 */
package org.nsanelab.dandy.ui.impl;

import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import javax.swing.*;
import java.awt.*;

import java.awt.event.ActionListener;
import java.beans.PropertyChangeListener;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import org.nsanelab.dandy.usecase.iface.IUIDependencyGraph;
import org.nsanelab.dandy.usecase.impl.ExportImage;
import org.nsanelab.dandy.usecase.impl.NW70Graph;

import java.util.LinkedHashSet;
import java.util.Set;
import org.nsanelab.dandy.utils.SetExtension;

/**
 * 
 * @author vin
 */
public class TopFrame extends javax.swing.JFrame implements ActionListener, PropertyChangeListener {

    /** Creates new form TopFrame */
    public TopFrame() {
        initComponents();
        genericUIInit();

    }

    public JTabbedPane getTabs() {
        return tabs;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed"
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        statusMgr = new org.nsanelab.dandy.ui.impl.StatusMngr();
        jDialog1 = new javax.swing.JDialog();
        popupMessage = new javax.swing.JLabel();
        tabs = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jProgressBar1 = new javax.swing.JProgressBar();
        statusLbl = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        topFile = new javax.swing.JMenu();
        fileNew = new javax.swing.JMenu();
        fileNew70Graph = new javax.swing.JMenuItem();
        fileNew70Graph1 = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JSeparator();
        jMenuItem1 = new javax.swing.JMenuItem();
        jSeparator4 = new javax.swing.JSeparator();
        newSave = new javax.swing.JMenuItem();
        fileSaveAs = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JSeparator();
        fileExport = new javax.swing.JMenuItem();
        jSeparator3 = new javax.swing.JSeparator();
        fileCloseAll = new javax.swing.JMenuItem();
        fileClose = new javax.swing.JMenuItem();
        topEdit = new javax.swing.JMenu();
        editLoopChk = new javax.swing.JMenu();
        editLoopCheckRuntime = new javax.swing.JMenuItem();
        editLoopCheckDCDep = new javax.swing.JMenuItem();
        topView = new javax.swing.JMenu();
        editRefresh = new javax.swing.JMenuItem();
        topHelp = new javax.swing.JMenu();
        helpManual = new javax.swing.JMenuItem();
        helpAbout = new javax.swing.JMenuItem();

        jDialog1.setTitle("Message");
        jDialog1.setAlwaysOnTop(true);
        jDialog1.setModal(true);
        jDialog1.setResizable(false);

        popupMessage.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        popupMessage.setText("messaggio");

        javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
        jDialog1.getContentPane().setLayout(jDialog1Layout);
        jDialog1Layout.setHorizontalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog1Layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(popupMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 423, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(29, Short.MAX_VALUE))
        );
        jDialog1Layout.setVerticalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog1Layout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addComponent(popupMessage)
                .addContainerGap(54, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jProgressBar1.setMaximum(statusMgr.getTaskSize());
        jProgressBar1.setToolTipText("Status");

        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${statusMgr.indeterminate}"), jProgressBar1, org.jdesktop.beansbinding.BeanProperty.create("indeterminate"));
        bindingGroup.addBinding(binding);
        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${statusMgr.taskSize}"), jProgressBar1, org.jdesktop.beansbinding.BeanProperty.create("maximum"));
        bindingGroup.addBinding(binding);
        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${statusMgr.taskCurrentStatus}"), jProgressBar1, org.jdesktop.beansbinding.BeanProperty.create("value"));
        bindingGroup.addBinding(binding);

        statusLbl.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        statusLbl.setLabelFor(jProgressBar1);
        statusLbl.setToolTipText("Current status");

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${statusMgr.status}"), statusLbl, org.jdesktop.beansbinding.BeanProperty.create("text"), "label");
        binding.setSourceNullValue("Sorgente nulla");
        binding.setSourceUnreadableValue("Sorgente non leggibile");
        bindingGroup.addBinding(binding);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(597, Short.MAX_VALUE)
                .addComponent(statusLbl, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(statusLbl, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 18, Short.MAX_VALUE)
                    .addComponent(jProgressBar1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        topFile.setText("File");

        fileNew.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/nsanelab/dandy/ui/impl/icons/32px-Crystal_Clear_action_filenew.png"))); // NOI18N
        fileNew.setText("New");
        fileNew.setToolTipText("Create a new graph");

        fileNew70Graph.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_G, java.awt.event.InputEvent.ALT_MASK));
        fileNew70Graph.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/nsanelab/dandy/ui/impl/icons/sap.png"))); // NOI18N
        fileNew70Graph.setText("NW70 DC dependency graph");
        fileNew70Graph.setToolTipText("Create a graph based on SAP component model, excluding relationship with standard components");
        fileNew70Graph.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fileNew70GraphActionPerformed(evt);
            }
        });
        fileNew70Graph.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                fileNew70GraphMouseClicked(evt);
            }
        });
        fileNew.add(fileNew70Graph);

        fileNew70Graph1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK));
        fileNew70Graph1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/nsanelab/dandy/ui/impl/icons/sap.png"))); // NOI18N
        fileNew70Graph1.setText("NW70 DC dependency graph (with standard DCs)");
        fileNew70Graph1.setToolTipText("Create a graph based on SAP component model, iccluding relationship with standard components");
        fileNew70Graph1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fileNew70Graph1ActionPerformed(evt);
            }
        });
        fileNew70Graph1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                fileNew70Graph1MouseClicked(evt);
            }
        });
        fileNew.add(fileNew70Graph1);
        fileNew70Graph1.getAccessibleContext().setAccessibleDescription("Create a graph based on SAP component model, including relationship with standard components");

        topFile.add(fileNew);
        topFile.add(jSeparator1);

        jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/nsanelab/dandy/ui/impl/icons/32px-Crystal_Clear_filesystem_folder_grey_open.png"))); // NOI18N
        jMenuItem1.setText("Open graph...");
        jMenuItem1.setToolTipText("Not supported yet");
        jMenuItem1.setEnabled(false);
        topFile.add(jMenuItem1);
        topFile.add(jSeparator4);

        newSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/nsanelab/dandy/ui/impl/icons/32px-Crystal_Clear_device_floppy_unmount.png"))); // NOI18N
        newSave.setText("Save");
        newSave.setToolTipText("Not suppported yet");
        newSave.setEnabled(false);
        newSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newSaveActionPerformed(evt);
            }
        });
        topFile.add(newSave);

        fileSaveAs.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/nsanelab/dandy/ui/impl/icons/32px-Crystal_Clear_app_kfloppy.png"))); // NOI18N
        fileSaveAs.setText("Save As...");
        fileSaveAs.setToolTipText("Not suppported yet");
        fileSaveAs.setEnabled(false);
        topFile.add(fileSaveAs);
        topFile.add(jSeparator2);

        fileExport.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.ALT_MASK));
        fileExport.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/nsanelab/dandy/ui/impl/icons/32px-Crystal_Clear_app_kpaint.png"))); // NOI18N
        fileExport.setText("Export...");
        fileExport.setToolTipText("Export existing graph to image file");
        fileExport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fileExportActionPerformed(evt);
            }
        });
        topFile.add(fileExport);
        topFile.add(jSeparator3);

        fileCloseAll.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK));
        fileCloseAll.setText("Close");
        fileCloseAll.setToolTipText("Close the current graph tab");
        fileCloseAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fileCloseActionPerformedHandler(evt);
            }
        });
        topFile.add(fileCloseAll);

        fileClose.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_K, java.awt.event.InputEvent.ALT_MASK));
        fileClose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/nsanelab/dandy/ui/impl/icons/32px-Crystal_Clear_action_exit.png"))); // NOI18N
        fileClose.setText("Close All");
        fileClose.setToolTipText("Close all tabs");
        fileClose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fileCloseAllActionPerformed(evt);
            }
        });
        topFile.add(fileClose);

        jMenuBar1.add(topFile);

        topEdit.setText("Edit");
        topEdit.setToolTipText("");

        editLoopChk.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/nsanelab/dandy/ui/impl/icons/32px-Crystal_Clear_action_run.png"))); // NOI18N
        editLoopChk.setText("Loop check");
        editLoopChk.setToolTipText("Check for loops in defined dependencies");

        editLoopCheckRuntime.setText("Library references loops");
        editLoopChk.add(editLoopCheckRuntime);

        editLoopCheckDCDep.setText("Used DCs loops");
        editLoopChk.add(editLoopCheckDCDep);

        topEdit.add(editLoopChk);

        jMenuBar1.add(topEdit);

        topView.setText("View");

        editRefresh.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F5, 0));
        editRefresh.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/nsanelab/dandy/ui/impl/icons/32px-Crystal_Clear_action_reload.png"))); // NOI18N
        editRefresh.setText("Refresh");
        editRefresh.setToolTipText("Forces rendering of current graph");
        editRefresh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editRefreshActionPerformed(evt);
            }
        });
        topView.add(editRefresh);

        jMenuBar1.add(topView);

        topHelp.setText("Help");

        helpManual.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/nsanelab/dandy/ui/impl/icons/32px-Crystal_Clear_app_khelpcenter.png"))); // NOI18N
        helpManual.setText("User Guide");
        topHelp.add(helpManual);

        helpAbout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/nsanelab/dandy/ui/impl/icons/32px-Crystal_Clear_action_bookmark.png"))); // NOI18N
        helpAbout.setText("About");
        topHelp.add(helpAbout);

        jMenuBar1.add(topHelp);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(tabs, javax.swing.GroupLayout.DEFAULT_SIZE, 905, Short.MAX_VALUE)
                .addGap(10, 10, 10))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(tabs, javax.swing.GroupLayout.DEFAULT_SIZE, 624, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void newSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newSaveActionPerformed
        // TODO add your handling code here:
        try {
            FileOutputStream fos = new FileOutputStream("C:\\test.xml");
            ObjectOutputStream oos = new ObjectOutputStream(fos);

            oos.writeObject(getGraphs().iterator().next());
        } catch (Exception ex) {
            ex.printStackTrace();
        }

    }//GEN-LAST:event_newSaveActionPerformed

    private void fileCloseAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileCloseAllActionPerformed
        // TODO add your handling code here:
        while (this.tabs.getComponentCount() != 0) {
            this.tabs.remove(0);
        }
    }//GEN-LAST:event_fileCloseAllActionPerformed

    private void fileCloseActionPerformedHandler(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileCloseActionPerformedHandler
        // TODO add your handling code here:
        this.fileCloseActionPerformed(evt);
}//GEN-LAST:event_fileCloseActionPerformedHandler

    private void fileNew70Graph1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileNew70Graph1ActionPerformed
        // TODO add your handling code here:
        IUIDependencyGraph newGraph;
        SwingWorker<Void, Void> graphWorker;
        newGraph = new NW70Graph(this);
        newGraph.setIncludeStandard(true);
        this.graphs.add(newGraph);
        graphWorker = (SwingWorker<Void, Void>) newGraph;
        graphWorker.addPropertyChangeListener(this);
        graphWorker.execute();
    }//GEN-LAST:event_fileNew70Graph1ActionPerformed

    private void fileNew70Graph1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_fileNew70Graph1MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_fileNew70Graph1MouseClicked

    private void genericUIInit() {
        this.setTitle("Dependency graph generator");
        this.graphs = new LinkedHashSet<IUIDependencyGraph>();
        this.statusMgr.setIndeterminate(false);
        this.statusMgr.setStatus(StatusMngr.ST_READY);
        this.statusMgr.setTaskCurrentStatus(StatusMngr.DEFAULT_TASK_SIZE);
        this.statusMgr.setTaskSize(StatusMngr.DEFAULT_TASK_SIZE);
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Dimension screenSize = toolkit.getScreenSize();
        int x = (screenSize.width - this.getWidth()) / 2;
        int y = (screenSize.height - this.getHeight()) / 2;
        this.setLocation(x, y);


    }

    public void setOperationRunning(String opToDisplay) {
        this.statusMgr.setIndeterminate(true);
        this.statusMgr.setStatus(opToDisplay);
    }

    public void setOperationStopped(String opToDisplay) {
        this.statusMgr.setIndeterminate(false);
        this.statusMgr.setStatus(opToDisplay);
    }

    public void setOperationCompletionLevel(int currSize, int maxSize) {
        this.statusMgr.setTaskCurrentStatus(currSize);
        this.statusMgr.setTaskSize(maxSize);
    }

    public StatusMngr getStatusMgr() {
        return statusMgr;
    }

    public void setStatusMgr(StatusMngr statusMgr) {
        StatusMngr oldStMgr;

        oldStMgr = this.statusMgr;
        this.statusMgr = statusMgr;

        firePropertyChange("statusMgr", oldStMgr, this.statusMgr);
    }

    /**
     * Refreshed the graph at the specified index
     * @param idx the index of the tab where the graph to be refreshed is located
     */
    public void refreshGraphAt(int idx) {
        IUIDependencyGraph[] graphArray;
        IUIDependencyGraph graph;
        JComponent renderedGraph;
        String title;

        graphArray = this.graphs.toArray(new IUIDependencyGraph[0]);
        graph = graphArray[idx];
        renderedGraph = graph.refreshGraph();

        title = this.tabs.getTitleAt(idx);
        this.tabs.remove(idx);
        this.tabs.add(renderedGraph, idx);
        this.tabs.setTitleAt(idx, title);
        this.setAllIcons();

    }

    public void showCriticalMessage(String message) {
    }

    public void setAllIcons() {
        int tabSetSize;
        Icon tabIcon;

        tabSetSize = this.tabs.getTabCount();
        tabIcon = new ImageIcon("src/org/nsanelab/dandy/ui/impl/icons/sap_small.png");
        for (int idx = 0; idx < tabSetSize; idx++) {
            this.tabs.setIconAt(idx, tabIcon);
        }

    }

    private void fileNew70GraphMouseClicked(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_fileNew70GraphMouseClicked
        // TODO add your handling code here:
    }// GEN-LAST:event_fileNew70GraphMouseClicked

    private void fileNew70GraphActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_fileNew70GraphActionPerformed
        // TODO add your handling code here:
        IUIDependencyGraph newGraph;
        SwingWorker<Void, Void> graphWorker;
        newGraph = new NW70Graph(this);
        this.graphs.add(newGraph);
        graphWorker = (SwingWorker<Void, Void>) newGraph;
        graphWorker.addPropertyChangeListener(this);
        graphWorker.execute();

    // return retVal;

    }// GEN-LAST:event_fileNew70GraphActionPerformed

    private void editRefreshActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_editRefreshActionPerformed
        // TODO add your handling code here:
        int currentTabIdx;
        currentTabIdx = this.tabs.getSelectedIndex();
        refreshGraphAt(currentTabIdx);
        this.tabs.setSelectedIndex(currentTabIdx);

    }// GEN-LAST:event_editRefreshActionPerformed

    private void fileCloseActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_fileCloseActionPerformed
        // TODO add your handling code here:
        SetExtension setExt;
        Component toRemove = this.getTabs().getSelectedComponent();
        IUIDependencyGraph[] graphArr = new IUIDependencyGraph[graphs.size()];
        //remove from tab list
        this.getTabs().remove(toRemove);
        int idx = this.getTabs().getSelectedIndex();
        //remove from graph set
        setExt = new SetExtension();
        setExt.setASet(this.graphs);

        try {
            this.graphs = setExt.remove(idx);
        } catch (IllegalArgumentException ex) {
            this.setOperationStopped(ex.getMessage());
        }



    }// GEN-LAST:event_fileCloseActionPerformed

    private void fileExportActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_fileExportActionPerformed
        // TODO add your handling code here:
        new ExportImage(this).doUseCase();
    }// GEN-LAST:event_fileExportActionPerformed

    /**
     * @param args
     *            the command line arguments
     */
    public static void main(String args[]) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        } catch (Exception e) {
            e.printStackTrace();
        }
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {

                new TopFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem editLoopCheckDCDep;
    private javax.swing.JMenuItem editLoopCheckRuntime;
    private javax.swing.JMenu editLoopChk;
    private javax.swing.JMenuItem editRefresh;
    private javax.swing.JMenuItem fileClose;
    private javax.swing.JMenuItem fileCloseAll;
    private javax.swing.JMenuItem fileExport;
    private javax.swing.JMenu fileNew;
    private javax.swing.JMenuItem fileNew70Graph;
    private javax.swing.JMenuItem fileNew70Graph1;
    private javax.swing.JMenuItem fileSaveAs;
    private javax.swing.JMenuItem helpAbout;
    private javax.swing.JMenuItem helpManual;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JProgressBar jProgressBar1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JMenuItem newSave;
    private javax.swing.JLabel popupMessage;
    private javax.swing.JLabel statusLbl;
    private org.nsanelab.dandy.ui.impl.StatusMngr statusMgr;
    private javax.swing.JTabbedPane tabs;
    private javax.swing.JMenu topEdit;
    private javax.swing.JMenu topFile;
    private javax.swing.JMenu topHelp;
    private javax.swing.JMenu topView;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables
    /**
     * @uml.property name="graphs"
     */
    private Set<IUIDependencyGraph> graphs;

    /**
     * Getter of the property <tt>graphs</tt>
     *
     * @return Returns the graphs.
     * @uml.property name="graphs"
     */
    public Set<IUIDependencyGraph> getGraphs() {
        return graphs;
    }

    /**
     * Setter of the property <tt>graphs</tt>
     *
     * @param graphs
     *            The graphs to set.
     * @uml.property name="graphs"
     */
    public void setGraphs(Set<IUIDependencyGraph> graphs) {
        this.graphs = graphs;
    }

    public void actionPerformed(ActionEvent arg0) {
        // throw new UnsupportedOperationException("Not supported yet.");
    }

    public void propertyChange(PropertyChangeEvent arg0) {
        //  throw new UnsupportedOperationException("Not supported yet.");
    }
}
